package com.site.controller.manage;

import com.site.service.TrialAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by robin on 2016/12/14.
 * 试用申请Controller
 */
@Controller
@RequestMapping("manage/trial")
public class TrialAppController{
    @Autowired
    private TrialAppService service;

    @RequestMapping("main")
    public String main(Model model){
        return "manage/system/trialApp/main";
    }

    @RequestMapping("search")
    public String search(Model model,String startDate,String endDate,String key,
                         int pageNum,@RequestParam(defaultValue = "5")int pageSize){
        Map param = new HashMap();
        param.put("startDate",startDate);param.put("endDate",endDate);param.put("key", key);
        model.addAttribute("data", service.search(param, pageNum, pageSize));
        return "manage/system/trialApp/search";
    }

    @RequestMapping("editRemark")
    @ResponseBody
    public int editRemark(String id,String remark){
        return service.edit(id,remark);
    }
}
